#ifdef _FULLPROGRAM

#include "klbltbl.h"
#include "kerror.h"

void LabelTable::AddLabel(const k_string &ident, k_uint position, k_uint ln)
{
	lbltbl_t::iterator it = this->table.find(ident);

	if (it != this->table.end())
		throw KCompileError(KCE_DUPLICATED_LABEL, ln);

	this->table[ident] = position;
}

void LabelTable::CleanUp()
{
	this->table.clear();
}

k_uint LabelTable::GetLabelPosition(const k_string &ident, k_uint ln) const
{
	lbltbl_t::const_iterator it = this->table.find(ident);

	if (it == this->table.end())
		throw KCompileError(KCE_UNDECLARED_LABEL, ln);

	return it->second;
}

#endif //_FULLPROGRAM
